class treasure_item extends eui.ItemRenderer {
	public constructor() {
		super();
		this.skinName = "resource/skins/items/treasure_item.exml";

		this.imgTreasure.addEventListener(egret.TouchEvent.TOUCH_BEGIN, this.onTouchTap, this);
		 

	}

	imgTreasure: eui.Image;
	imgShadow: eui.Image;
	group: eui.Group;

	isOnTouch=false;

	protected dataChanged() {
		// console.log("datachange...")
		if (this.data) {
			// console.log("treasure..xy",this.data.x,this.data.y);
			this.group.x = this.data.x;
			this.group.y = this.data.y;
			this.group.scaleY = 0;
			this.group.scaleX = 0;
			egret.Tween.get(this.group).to({ scaleX: 1.2, scaleY: 1.2 }, 200).to({ scaleX: 1, scaleY: 1 }, 60);
		}
	}


 

	private async onTouchTap() {
		if(this.isOnTouch){
			return ;
		}
		this.isOnTouch=true;
		Events.dispatch(Events.Type.OPEN_TREASURE, this.data.qualityType);
		await ClientManager.ins().openTreasue(this.imgTreasure,this.data);
	}

}